package com.sumainfor.pc.epc.controller.tenant;

import com.sumainfor.common.util.FieldCheckUtil;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.epc.service.TcepcArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * <p>
 *查询保修物品相关清单
 * <p>
 *
 * @author: Mr.Wang
 * @create: 2019-04-16 15:13
 **/
@Controller
@RequestMapping("/tenant/key/tcepcArticle")
public class TcepcArticleController {
    @Autowired
    TcepcArticleService tcepcArticleService;


    /**
    * <p>
    *查询受理中的维修工单
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/toAccept")
    public JsonResult toAccept(@RequestBody Map<String,Object> params){
        return tcepcArticleService.toAccept(params);
    }

    /**
    * <p>
    *查询待上门
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/forTheDoor")
    public JsonResult forTheDoor(@RequestBody Map<String,Object> params){
        return tcepcArticleService.forTheDoor(params);
    }

    /**
    * <p>
    *查询待支付
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/toBePaid")
    public JsonResult toBePaid(@RequestBody Map<String,Object> params){
        return tcepcArticleService.toBePaid(params);
    }

    /**
    * <p>
    * 查询待评价
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/toEvaluate")
    public JsonResult toEvaluate(@RequestBody Map<String,Object> params){
        return tcepcArticleService.toEvaluate(params);
    }

    /**
    * <p>
    *查询已完成
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/hasBeenCompleted")
    public JsonResult hasBeenCompleted(@RequestBody Map<String,Object> params){
        return tcepcArticleService.hasBeenCompleted(params);
    }


    /**
    * <p>
    * 查询维修师傅的平均评价
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/getStarAvg")
     public JsonResult getStarAvg(@RequestBody Map<String,Object> params){
        return tcepcArticleService.getStarAvg(params);
    }

    /**
    * <p>
    * 取消预约
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/deleteTcepcRepair")
    public JsonResult deleteTcepcRepair(@RequestBody Map<String,Object> params){
        return tcepcArticleService.deleteTcepcRepair(params);
    }

    /**
    * <p>
    * 增加维修评价
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/insertRepairEva")
    public JsonResult insertRepairEva(@RequestBody Map<String,Object> params){
        System.out.println(params);
        return tcepcArticleService.insertRepairEva(params);
    }

    /**
    * <p>
    *查询保修物品清单分类
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/getTcepcArticleType")
    public JsonResult getTcepcArticleType(){
        return tcepcArticleService.getTcepcArticleType();
    }

    /**
    * <p>
    * 查询保修物品清单
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/getTcepcArtice")
    public JsonResult getTcepcArtice(@RequestBody Map<String,Object> params){
        return tcepcArticleService.getTcepcArtice(params);
    }

    /**
    * <p>
    * 根据保修物品编号获取物品故障描述
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/getTcepcArticleTrouble")
    public JsonResult getTcepcArticleTrouble(@RequestBody Map<String,Object> params){
        return tcepcArticleService.getTcepcArticleTrouble(params);
    }

    /**
    * <p>
    *  根据租客在线保修物品信息添加维修工单
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @PostMapping("/insertTcepcRepair")
    public JsonResult insertTcepcRepair(@RequestBody Map<String,Object> params){
        JsonResult result = new JsonResult();
        if(!FieldCheckUtil.isMapFieldNotNull(params ,new String[]{"HouCon"})){
            return  result.putFailed("参数不完整");
        }
        return tcepcArticleService.insertTcepcRepair(params);
    }

}
